package org.karai.frame.presenter;

import android.app.Activity;
import android.view.View;
import android.widget.TextView;

import org.karai.frame.core.base.IBasePresenter;
import org.karai.frame.model.ITestModel;
import org.karai.frame.view.ITestView;


/**
 * 持有model 和 view 视图和持久层数据交换的接口
 * @author karai
 */
public class ITestPresenter implements IBasePresenter  {


    private ITestModel mITestModel ;
    private ITestView mITestView;
    private Activity mActivity;

    public ITestPresenter() {
    }

    public ITestPresenter(ITestModel ITestModel, ITestView ITestView , Activity activity) {
        mITestModel = ITestModel;
        mITestView = ITestView;
        this.mActivity = activity;
    }

    /**
     * 业务处理逻辑
     * @param view
     */
    public void doThings(TextView view){
        view.setOnClickListener(v -> {
            this.mITestModel.handleThings(this.mActivity , this);
        });

    }

    @Override
    public String success(String code, String res) throws Exception {
        this.mITestView.showDoThingsResult(res);
        return null;
    }

    @Override
    public String error(String code, String err) throws Exception {
        return null;
    }
}
